package actor.attribute
{
	import actor.event.TowerEvent;
	
	import capricornus.actor.attribute.ActorAttribute;
	
	public class TowerAttribute extends ActorAttribute
	{
		//攻击速度， 单位ms
		private var _attackSpeed:int = 0;
		//攻击伤害
		private var _damage:int = 0;
		//攻击范围
		private var _range:int = 0;
		//发射子弹ID
		private var _bulletID:int = 0;
		//占用格子数
		private var _useGrid:int = 1;
		//多重箭数量，一般为1，即单体攻击
		private var _bulletCount:int = 1;
		//重砍几率(0~1)
		private var _criticalStrikeRate:Number = 0;
		//重砍倍数
		private var _criticalStrikeMulti:Number = 0;
		//击晕几率(0~1)
		private var _stunRate:Number = 0;
		//击晕附加伤害
		private var _stunDamage:int = 0;
		//击晕时间（ms）；
		private var _stunDuration:int = 0;
		
		public function TowerAttribute()
		{
			super();
		}
		
		public function get attackSpeed():int
		{
			return _attackSpeed;
		}
		
		public function get damage():int
		{
			return _damage;
		}
		
		public function get range():int
		{
			return _range;
		}
		
		public function get bulletID():int
		{
			return _bulletID;
		}
		
		public function get useGrid():int
		{
			return _useGrid;
		}
		
		public function get bulletCount():int
		{
			return _bulletCount;
		}
		
		public function get criticalStrikeRate():Number
		{
			return _criticalStrikeRate;
		}
		
		public function get criticalStrikeMulti():Number
		{
			return _criticalStrikeMulti;
		}
		
		public function get stunRate():Number
		{
			return _stunRate;
		}
		
		public function get stunDamage():int
		{
			return _stunDamage;
		}
		
		public function get stunDuration():int
		{
			return _stunDuration;
		}
		
		public function setAttackSpeed( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _attackSpeed != value )
			{
				_attackSpeed = value;
				if( dispatchEvent ) this.dispatchEvent( new TowerEvent( TowerEvent.ATTACK_SPEED_CHANGE, _attackSpeed ) );
			}
		}
		
		public function setDamage( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _damage != value )
			{
				_damage = value;
				if( dispatchEvent ) this.dispatchEvent( new TowerEvent( TowerEvent.DAMAGE_CHANGE, _damage ) );
			}
		}
		
		public function setRange( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _range != value )
			{
				_range = value;
				if( dispatchEvent ) this.dispatchEvent( new TowerEvent( TowerEvent.RANGE_CHANGE, _range ) );
			}
		}
		
		public function setBulletID( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _bulletID != value )
			{
				_bulletID = value;
				if( dispatchEvent ) this.dispatchEvent( new TowerEvent( TowerEvent.BULLET_ID_CHANGE, _bulletID ) );
			}
		}
		
		public function setUseGrid( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _useGrid != value )
			{
				_useGrid = value;
				if( dispatchEvent ) this.dispatchEvent( new TowerEvent( TowerEvent.USE_GRID_CHANGE, _useGrid ) );
			}
		}
		
		public function setBulletCount( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _bulletCount != value )
			{
				_bulletCount = value;
				if( dispatchEvent ) this.dispatchEvent( new TowerEvent( TowerEvent.BULLET_COUNT_CHANGE, _useGrid ) );
			}
		}
		
		public function setCriticalStrikeRate( value:int, dispatchEvent:Boolean=true ):void
		{
			var f:Number = value/100;
			if( f > 1 ) f = 1;
			if( _criticalStrikeRate != f )
			{
				_criticalStrikeRate = f;
			}
		}
		
		public function setCriticalStrikeMulti( value:Number, dispatchEvent:Boolean=true ):void
		{
			if( _criticalStrikeMulti != value )
			{
				_criticalStrikeMulti = value;
			}
		}
		
		public function setStunRate( value:int, dispatchEvent:Boolean=true ):void
		{
			var f:Number = value/100;
			if( f > 1 ) f = 1;
			if( _stunRate != f )
			{
				_stunRate = f;
			}
		}
		
		public function setStunDamage( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _stunDamage != value )
			{
				_stunDamage = value;
			}
		}
		
		public function setStunDuration( value:int, dispatchEvent:Boolean=true ):void
		{
			if( _stunDuration != value )
			{
				_stunDuration = value;
			}
		}
	}
}